feat(velocity): make discovery config env-var driven#36
Merged
Conversation
Replaces the hardcoded `companion object` constants in DiscoveryService with a `DiscoveryConfig` data class loaded from environment variables. All keys are optional and the defaults match the previous hardcoded behaviour, so existing prod deployments are unaffected. New env vars (all optional): - GROUNDS_AGONES_NAMESPACE (falls back to POD_NAMESPACE Downward API, then "games") - GROUNDS_AGONES_LABEL_SELECTOR (empty string = no k8s-side filter) - GROUNDS_AGONES_LOBBY_LABEL (empty string = treat every running GS as lobby — useful in per-dev / staging clusters) - GROUNDS_AGONES_LOBBY_VALUE - GROUNDS_AGONES_RUNNING_STATES (CSV) - GROUNDS_AGONES_POLL_INTERVAL (2s / 5m / 1h) - GROUNDS_AGONES_ADDRESS_TYPE (PodIP / ExternalIP / …) - GROUNDS_AGONES_PORT Motivation: the same plugin needs to run in three contexts — prod (games namespace, server-type filter), per-dev vClusters (Phase 3.1a in grounds-platform: own namespace, no role filtering), and the shared staging cluster (Phase 3.2). Cloud-native config via env vars + ConfigMap envFrom + Downward API is the Kubernetes-idiomatic shape and avoids forking the plugin per context. Plugin entrypoint logs the resolved config on startup so operators can see what is actually loaded. 14 unit tests in DiscoveryConfigTest cover defaults, override precedence, empty/whitespace-handling, malformed values, and the per-dev cluster preset. Adds JUnit 5 testImplementation to the velocity module (no tests existed before).
|
lusu007
approved these changes
Apr 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Replaces the hardcoded
companion objectconstants inDiscoveryServicewith aDiscoveryConfigdata class loaded from environment variables. All keys are optional; defaults match the previous hardcoded behaviour, so existing prod deployments are unaffected (no chart change required).New env vars (all optional)
GROUNDS_AGONES_NAMESPACEgames(falls back toPOD_NAMESPACEfirst)GROUNDS_AGONES_LABEL_SELECTORgrounds/server-type in (lobby,game,match)GROUNDS_AGONES_LOBBY_LABELgrounds/server-typeGROUNDS_AGONES_LOBBY_VALUElobbylobbyLabelthat marks a lobbyGROUNDS_AGONES_RUNNING_STATESReady,Allocated,ReservedGROUNDS_AGONES_POLL_INTERVAL2sNs/Nm/NhGROUNDS_AGONES_ADDRESS_TYPEPodIPPodIP/ExternalIP/InternalIP/HostnameGROUNDS_AGONES_PORT25565Why
Even ignoring any specific context, configurable beats hardcoded for a plugin like this:
The plugin entrypoint logs the resolved config on startup so operators can see what's loaded.
Test plan
Adds JUnit 5 `testImplementation` to the velocity module (no tests existed before).